var post_jsondata = parent.$("#post_jsondata").val();
var index = parent.layer.getFrameIndex(window.name);
var modelId = parent.$("#modelid").val();
var isSave = false;
window.onload = function(){
    $('#saveTask').click(function () {
        if(!isSave){
            layer.load(2);
            isSave = true;
            var name = $("#name").val();
            var InputText1 = $("#InputText1").val();
            $.ajax({
                url:constUrl+"ws/task/list",
                type:'post',
                data:{
                    "operateType":"addTask",
                    "modelId":modelId,
                    "userName":"tentative",
                    "name":name,
                    "introduction":InputText1,
                    "json":post_jsondata,//模型的整体json
                    "nestJson":""//嵌套部分的json
                },
                dataType:'json',
                success: function(responseText) {
                    layer.closeAll('loading');
                    if(responseText.result) {
                        parent.layer.alert("保存成功！");
                        parent.$('#taskname').html("任务名："+name);
                        parent.$('#taskid').val(responseText.taskId);
                        parent.$('#button_start').attr("disabled", false);
                        parent.$('#button_save').attr("disabled", true);
                        parent.$('#taskid').val(responseText.taskId);
                        parent.layer.close(index);
                    }
                },
                error: function() {
                    isSave = false;
                    layer.closeAll('loading');
                    layer.alert("保存失败！");
                    parent.layer.close(index);
                }
            });
        }
    });
    $('#closeIframe').click(function(){
    	parent.layer.close(index);
    });
}